package com.nwpu.server.search.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.nwpu.server.search.entity.GeneTableEntity;
import com.nwpu.server.search.service.GeneTableService;
import com.nwpu.server.common.response.*;



/**
 * 
 *
 * @author YuXingZh
 * @email 617058979@qq.com
 * @date 2022-04-10 11:27:38
 */
@RestController
@RequestMapping("search/genetable")
public class GeneTableController {
    @Autowired
    private GeneTableService geneTableService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = geneTableService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{ensemblGeneId}")
    public R info(@PathVariable("ensemblGeneId") String ensemblGeneId){
		GeneTableEntity geneTable = geneTableService.getById(ensemblGeneId);

        return R.ok().put("geneTable", geneTable);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody GeneTableEntity geneTable){
		geneTableService.save(geneTable);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody GeneTableEntity geneTable){
		geneTableService.updateById(geneTable);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] ensemblGeneIds){
		geneTableService.removeByIds(Arrays.asList(ensemblGeneIds));

        return R.ok();
    }

}
